const checkUserStat = require('./middleware/checkUserStat') // 验证用户状态 中间件
const Router = require('koa-router')
const router = new Router()

// UpFile
const UpFile = require('./controller/UpFile')
router.post('/fileUpload', (ctx) => UpFile.index(ctx))
router.post('/batchUpload', (ctx) => UpFile.batchUpload(ctx))
router.post('/getChunkList', (ctx) => UpFile.getChunkList(ctx))
router.post('/single', (ctx) => UpFile.single(ctx))
router.post('/merge', (ctx) => UpFile.merge(ctx))

// admin
const Admin = require('./controller/Admin')
router.post('/admin/user/login', (ctx) => Admin.login(ctx))
router.get('/admin/user/info', checkUserStat, (ctx) => Admin.getUserInfo(ctx))
router.post('/admin/user/logout', (ctx) => Admin.userLogout(ctx))
router.get('/admin/user/list', (ctx) => Admin.userList(ctx))

// api
const Api = require('./controller/Api')
router.get('/api/newsList', (ctx) => Api.newsList(ctx))
router.get('/api/newsListDf', (ctx) => Api.newsListDf(ctx))
router.get('/api/mockdata', (ctx) => Api.mockdata(ctx))
router.get('/api/listData', (ctx) => Api.listData(ctx))
router.get('/api/listDataSleep', (ctx) => Api.listDataSleep(ctx))
router.get('/api/cityList', (ctx) => Api.cityList(ctx))
router.get('/api/richtext', (ctx) => Api.richtext(ctx))
router.get('/api/cityListAll', (ctx) => Api.cityListAll(ctx))
router.get('/api/userList', (ctx) => Api.userList(ctx))
router.get('/api/commentList', (ctx) => Api.commentList(ctx))
router.post('/api/apiCache', (ctx) => Api.apiCache(ctx))
router.all('/api/getApiCache', (ctx) => Api.getApiCache(ctx))

// Home
const Home = require('./controller/Home')
router.get('/home/navlist', (ctx) => Home.homeNavList(ctx))
router.get('/home/getWebPage', (ctx) => Home.getWebPage(ctx))

// MrGame
const MrGame = require('./controller/MrGame')
router.post('/game/admin/user/login', (ctx) => MrGame.login(ctx))
router.post('/game/gameCount', (ctx) => MrGame.gameCount(ctx))
router.get('/game/getLogs', checkUserStat, (ctx) => MrGame.getLogs(ctx))
router.get('/game/removeLogById', checkUserStat, (ctx) =>
  MrGame.removeLogById(ctx)
)
router.get('/game/clearAllLog', checkUserStat, (ctx) => MrGame.clearAllLog(ctx))

// CryptoMenu
const CryptoMenu = require('./controller/CryptoMenu')
router.post('/createCrypto', (ctx) => CryptoMenu.createCrypto(ctx))
router.post('/aesCrypto', (ctx) => CryptoMenu.aesCrypto(ctx))

module.exports = router
